// pages/home/home.js
var app = getApp();
Page({

  /**
   * 页面的初始数据
   */
  data: {
    imgUrls: [
      "https://img.chenchen520.cn/shop/banners/banner-1.jpg",
      "https://img.chenchen520.cn/shop/banners/banner-2.jpg",
      "https://img.chenchen520.cn/shop/banners/banner-3.jpg"
    ],
    indicatorDots: true,
    indicatorColor: "#fff",
    indicatorActiveColor: "#956BFF",
    autoplay: true,
    interval: 3000,
    duration: 1000,
    classes: [{
        name: "邀请有礼",
        img: "https://img.chenchen520.cn/shop/yqyl.png",
        url: "../logs/logs"
      },
      {
        name: "春节福利",
        img: "https://img.chenchen520.cn/shop/cjfl.png",
        url: "../logs/logs"
      },
      {
        name: "酷币商城",
        img: "https://img.chenchen520.cn/shop/kbsc.png",
        url: "../logs/logs"
      },
      {
        name: "手机通讯",
        img: "https://img.chenchen520.cn/shop/sjtx.png",
        url: "../logs/logs"
      },
      {
        name: "手机配件",
        img: "https://img.chenchen520.cn/shop/sjpj.png",
        url: "../logs/logs"
      }
    ],
    msgList: [{
        url: "url",
        title: "多地首套房贷利率上浮 热点城市渐迎零折扣时代"
      },
      {
        url: "url",
        title: "悦如公寓三周年生日趴邀你免费吃喝欢唱"
      },
      {
        url: "url",
        title: "你想和一群有志青年一起过生日嘛？"
      }
    ],
    ms_products: [{
        id: 1,
        url: "https://m.360buyimg.com/n1/jfs/t15787/353/109633918/16701/5a8390ef/5a27ae6dNc530b5bb.jpg!q70.jpg",
        price: "3800.00",
        price_del: "12000.00"
      },
      {
        id: 2,
        url: "https://m.360buyimg.com/mobilecms/s240x240_jfs/t14287/16/2071526173/41836/766c1953/5a6935d3N17ca68e7.jpg!q70.jpg",
        price: "89.90",
        price_del: "128.89"
      },
      {
        id: 3,
        url: "https://m.360buyimg.com/mobilecms/s240x240_jfs/t15049/171/1967249015/25679/d554d9a9/5a61d929N027318e3.jpg!q70.jpg",
        price: "1900.00",
        price_del: "2200.00"
      },
      {
        id: 4,
        url: "https://m.360buyimg.com//mobilecms/s276x276_jfs/t13030/75/2301251503/262030/ed6dc00d/5a3a09beN645f27a8.jpg!q70.jpg",
        price: "35.00",
        price_del: "38.00"
      },
      {
        id: 5,
        url: "https://m.360buyimg.com//mobilecms/s276x276_jfs/t11401/34/504898878/183378/5a6a8a48/59f1c3a1N2174c8cc.jpg!q70.jpg",
        price: "38.00",
        price_del: "50.00"
      },
    ],
    ads: [{
        url: "",
        image: "https://s2.juancdn.com/jas/180125/a/0/5a6991598150a12f8a70b929_1080x292.gif"
      },
      {
        url: "",
        image: "https://s2.juancdn.com/jas/180125/a/0/5a6991598150a12f8a70b929_1080x292.gif"
      },
      {
        url: "",
        image: "https://s2.juancdn.com/jas/180125/a/0/5a6991598150a12f8a70b929_1080x292.gif"
      },
      {
        url: "",
        image: "https://s2.juancdn.com/jas/180125/a/0/5a6991598150a12f8a70b929_1080x292.gif"
      },
      {
        url: "",
        image: "https://s2.juancdn.com/jas/180125/a/0/5a6991598150a12f8a70b929_1080x292.gif"
      }
    ],
    products: [{
        id: 6,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com/n1/jfs/t15787/353/109633918/16701/5a8390ef/5a27ae6dNc530b5bb.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      },
      {
        id: 7,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com/mobilecms/s240x240_jfs/t14125/285/900232321/14466/12dfc3a3/5a163dd1Ne09fad4b.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      },
      {
        id: 8,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com/mobilecms/s240x240_jfs/t15811/137/1521616135/14255/a6150285/5a546fadN096d46b4.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      },
      {
        id: 9,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com//mobilecms/s276x276_jfs/t5848/205/6830434960/124593/19e83624/596c8b4eN3c8ba6a7.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      },
      {
        id: 10,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com/n1/jfs/t15787/353/109633918/16701/5a8390ef/5a27ae6dNc530b5bb.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      },
      {
        id: 11,
        title: "Apple 苹果 iPhoneX 全新发布",
        price: "8088.00",
        image: "https://m.360buyimg.com//mobilecms/s276x276_jfs/t5848/205/6830434960/124593/19e83624/596c8b4eN3c8ba6a7.jpg!q70.jpg",
        category: "vip专享",
        rules: "全网通 64G 深空灰"
      }
    ]
  },
  /**
   * 跳转详细页
   */
  toDetail: function(event) {
    var id = event.currentTarget.dataset.id;
    wx.navigateTo({
      url: '../detail/detail',
    })
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var date = new Date();
    var data = {
      'username': 'chenchen',
      'email': '956603199@qq.com',
      'password': app.md5('123456'),
      'timestamp':date.getTime()
    };
    var sign = app.sign(data);
    var encrypt = app.encrypt(data);
    var decrypt = app.decrypt(encrypt);
    console.log("签名结果："+sign);
    console.log("验签结果：" + app.verify(data,sign));
    console.log("加密结果：" + encrypt);
    console.log("解密结果：" + decrypt);
    wx.request({
      url: 'https://pmg.chenchen520.cn/api/index/getsign',
      data:data,
      header: {
        'content-type': 'application/x-www-form-urlencoded' //坑爹货……默认值为:application/json，导致后台一直接收不到数据
      },
      method:'POST',
      success:function(res){
        console.log(res);
      },
      fail:function(msg){
        console.log(msg);
      }
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})